package com.pth.admin.action;

import java.io.File;

import com.opensymphony.xwork2.ActionSupport;
import com.pth.model.Jianjie;
import com.pth.service.JianjieService;
import com.pth.utils.FileUtils;
import com.pth.utils.JianjieSign;
import com.pth.utils.TomcatAPI;
import com.pth.utils.timeUtil;

public class Add_jianjie_imageAction extends ActionSupport {

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Jianjie jianjie;
	private JianjieService jianjieService;
	private File image;
	public File getImage() {
		return image;
	}
	public void setImage(File image) {
		this.image = image;
	}


	private String imageFileName;
	private String imageContentType;
	
	
	
	public String getImageFileName() {
		return imageFileName;
	}
	public void setImageFileName(String imageFileName) {
		this.imageFileName = imageFileName;
	}
	public String getImageContentType() {
		return imageContentType;
	}
	public void setImageContentType(String imageContentType) {
		this.imageContentType = imageContentType;
	}
	@Override
	public String execute() throws Exception {

		FileUtils.fileUpload(image, imageFileName, imageContentType,"/files/jianjie" );
		jianjie.setSign(JianjieSign.IMAGE);
		jianjie.setImagepath("files/jianjie/"+imageFileName);
		jianjie.setPublishtime(timeUtil.getCurrentDate());
		jianjieService.add(jianjie);
	
		return SUCCESS;
	
	}
	public Jianjie getJianjie() {
		return jianjie;
	}
	public JianjieService getJianjieService() {
		return jianjieService;
	}
	public void setJianjie(Jianjie jianjie) {
		this.jianjie = jianjie;
	}
	
	
	public void setJianjieService(JianjieService jianjieService) {
		this.jianjieService = jianjieService;
	}
	
	
}
